home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / keyboard.swg / 0084_Increasing Keyboard Buffer.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-26  |  2.5 KB  |  94 lines

  1. {
  2.  > Does anyone know how to increase the size of the keyboard buffer? I need
  3.  > to be able to pump out more than 16 bytes to the buffer.
  4.  
  5. This is a resident utility I wrote myself for this purpose.
  6.  
  7. It has to be loaded in conventional memory (NOT LoadHigh) at an address lower
  8. than $10400, preferrably immediately after Keyb.com.
  9.  
  10. One warning: there may be programs around (very old XT-programs, or bad
  11. programs), which will try to access the keyboard buffer at it's standard
  12. address $40:$1E. If you use one of these programs, the machine will crash.
  13. }
  14.  
  15. {*********************************************
  16.  * Installs keyboard buffer of any size      *
  17.  * Usage: bigkey [bufparas]                  *
  18.  * Bufparas: desired size of keyboard buffer *
  19.  *           in paragraphs (16 bytes)        *
  20.  *           default : 10 <-> 79 chars       *
  21.  *                                           *
  22.  * The size of the resident program will be  *
  23.  * 96 bytes + buffer size.                   *
  24.  *                                           *
  25.  * Horst Kraemer  2:2410/121.16@fidonet.org  *
  26.  * 30.06.92                                  *
  27.  *********************************************}
  28.  
  29. program bigkey;
  30.  
  31. uses
  32.   dos;
  33.  
  34. const
  35.   PSPOffset=6;
  36.  
  37. var
  38.   KeyBufTail  : word absolute $40:$1A;
  39.   KeyBufHead  : word absolute $40:$1C;
  40.   KeyBufStart : word absolute $40:$80;
  41.   KeyBufEnd   : word absolute $40:$82;
  42.   EnvSeg,Dist,BufParas,Code:word;
  43.  
  44. procedure usage;
  45. begin
  46.   writeln('Usage: bigkey [bufparas]');
  47.   writeln('bufparas: size of buffer in paragraphs (>2)');
  48.   writeln('          default : 10 <-> 79 chars');
  49.   halt(1)
  50. end;
  51.  
  52. begin
  53.   if paramcount>1 then Usage;
  54.   if paramcount=0 then
  55.     BufParas:=10
  56.   else begin
  57.     val(paramstr(1),BufParas,Code);
  58.     if (Code<>0) or (BufParas<=2) then Usage
  59.   end;
  60.  
  61.   Dist:=prefixseg+PSPOffset-$40; {Distance BIOS segment <-> start of buffer}
  62.  
  63.   if Dist+BufParas >= $1000 then begin
  64.     writeln('End of buffer not in BIOS segment');
  65.     Halt(1)
  66.   end
  67.   else
  68.     writeln('Buffer for ',BufParas*8-1,' characters installed');
  69.  
  70.   Dist:=Dist shl 4; {Offset of buffer relative to BIOS segment}
  71.  
  72.   asm cli end;
  73.   KeyBufTail  := Dist;
  74.   KeyBufHead  := Dist;
  75.   KeyBufStart := Dist;
  76.   KeyBufEnd   := Dist + BufParas shl 4;
  77.   asm sti end;
  78.  
  79.   { Free environment and leave only
  80.     keyboard buffer in memory
  81.   }
  82.   swapvectors;
  83.   envseg:=memw[prefixseg:$2c];
  84.   asm
  85.     mov es,envseg
  86.     mov ah,49h
  87.     int 21h
  88.     mov dx,PSPOffset
  89.     add dx,BufParas
  90.     mov ax,3100h
  91.     int 21h
  92.   end;
  93. end.
  94.